﻿using MediatR;

namespace Messhall.Application.Permission.Commands.Permission;

public class RemovePermissionCommandHandler : CommandHandlerBase, IRequestHandler<RemovePermissionCommand, bool>
{
    public async Task<bool> Handle(RemovePermissionCommand removePermissionCommand, CancellationToken cancellationToken)
    {
        var request = removePermissionCommand.Request ?? throw new ArgumentNullException("request is null");

        await base.permissionRepository.DeleteAsync(request.KeyIds.ToArray());

        await appUnitOfWork.SaveChangesAsync();
        
        return true;
    }
}